import D3.Matrix;
import D3.Polygon;
import D3.Vertex;

dynamic class D3.ProjectTranceCallBack{
	private static var $withDepth:Boolean=true;
	private static var $withProject:Boolean=true;
	private static var $withLocatioin:Boolean=true;
	public static var DistroyPoint:Vertex=new Vertex("distroyPoint",0,0,-200);	//
	public static var ProjectMcToScreen:Function;  //ProjectMcToScreen(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip);
	public static var ProjectOnProjectMcToScreen:Function;  //ProjectOnProjectMcToScreen(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip);
	public static var DepthOnProjectMcToScreen:Function;	//depthsOnProjectMcToScreen(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip);
	public static var LocationOnProjectMcToScreen:Function; //LocationOnProjectMcToScreen(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip);
	//if use default depth function
	public static function get WithDepth(){
		return ProjectTranceCallBack.$withDepth;
	}
	public static function set WithDepth(value:Boolean){
		ProjectTranceCallBack.$withDepth=value;
	}
	//if use default project function
	public static function get WithProject(){
		return ProjectTranceCallBack.$withProject;
	}
	public static function set WithProject(value:Boolean){
		ProjectTranceCallBack.$withProject=value;
	}
	//if use default location function
	public static function get WithLocatioin(){
		return ProjectTranceCallBack.$withLocatioin;
	}
	public static function set WithLocatioin(value:Boolean){
		ProjectTranceCallBack.$withLocatioin=value;
	}
	
	//
	public static function ProjectMcInvoke(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip,dorwAxes:Boolean){
		if(ProjectTranceCallBack.ProjectMcToScreen==undefined){
			ProjectTranceCallBack.projectMC(sender,PointAfterProject,bangdingMC);
		}else{
			ProjectTranceCallBack.ProjectMcToScreen(sender,PointAfterProject,bangdingMC);
		}
		
	}
//	public static function DorwAxes(sender:Polygon)
	private static function projectMC(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip){
		if(ProjectTranceCallBack.$withLocatioin){
			if(ProjectTranceCallBack.LocationOnProjectMcToScreen==undefined){
				ProjectTranceCallBack.LocationOnProjectMC(sender,PointAfterProject,bangdingMC);
			}else{
				ProjectTranceCallBack.LocationOnProjectMcToScreen(sender,PointAfterProject,bangdingMC);
			}
		}
		
		if(ProjectTranceCallBack.$withDepth){
			if(ProjectTranceCallBack.DepthOnProjectMcToScreen==undefined){
				ProjectTranceCallBack.DepthOnProjectMC(sender,PointAfterProject,bangdingMC);
			}else{
				ProjectTranceCallBack.DepthOnProjectMcToScreen(sender,PointAfterProject,bangdingMC);
			}
		}
		
		if(ProjectTranceCallBack.$withProject){
			if(ProjectTranceCallBack.ProjectOnProjectMcToScreen==undefined){
				ProjectTranceCallBack.ProjectOnProjectMC(sender,PointAfterProject,bangdingMC);
			}else{
				ProjectTranceCallBack.ProjectOnProjectMcToScreen(sender,PointAfterProject,bangdingMC);
			}
		}
	}
	///projects
	public static function ProjectOnProjectMC(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip){
		var bl:Number=(ProjectTranceCallBack.DistroyPoint._Z-PointAfterProject._Z)/ProjectTranceCallBack.DistroyPoint._Z;
		bl=Math.max(bl,0);
		bangdingMC._x*=bl;
		bangdingMC._y*=bl;
		bangdingMC._z*=bl;
		bangdingMC._yscale=bangdingMC._xscale=100*bl;
	}
	///locations
	public static function DepthOnProjectMC(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip){
		bangdingMC._x=PointAfterProject._X;
		bangdingMC._y=PointAfterProject._Y;
		bangdingMC._z=PointAfterProject._Z;
	}
	//dipths
	public static function LocationOnProjectMC(sender:Object,PointAfterProject:Vertex,bangdingMC:MovieClip){
		var d:Number=(PointAfterProject._Z*5000)+500000;
		bangdingMC.swapDepths(d);
	}
	
}